package com.wq.gof.designer.chain.pointer;

import com.wq.gof.designer.chain.EventHandler;

import java.util.Random;

/**
 * @Author: wangqiang20995
 * @Date:2019/1/25
 * @Description:
 * @Resource:
 */
public abstract class AbstractPointerEventHandler implements EventHandler<PointerConditions> {

    private AbstractPointerEventHandler nextHandler;

    public abstract void doHandler(String name, Integer level);

    public abstract long frequency();

    @Override
    public void handle(PointerConditions conditions) {
        Integer level = new Random().nextInt(conditions.getLevel());
        doHandler(conditions.getName(),level);
    }

    public AbstractPointerEventHandler getNextHandler() {
        return nextHandler;
    }

    public void setNextHandler(AbstractPointerEventHandler nextHandler) {
        this.nextHandler = nextHandler;
    }
}
